package com.lei.synchronized_upgrade.lockCoarsing;

/**
 * @Author: Doream
 * @Date: 2022/3/19 10:01
 */
public class Demo01 {
    public static void main(String[] args) {
        StringBuffer stringBuffer = new StringBuffer();

        //synchronized (stringBuffer){ 锁粗化
            for (int i = 0; i < 100; i++) {
                stringBuffer.append("a");
                /**
                 *     @HotSpotIntrinsicCandidate
                 *     public synchronized StringBuffer append(String str) {
                 *         this.toStringCache = null;
                 *         super.append(str);
                 *         return this;
                 *     }
                 */
            }
        //}

        System.out.println(stringBuffer.toString());
    }
}
